// @ES6允许按照一定模式从数组和对象中提取值,对变量进行赋值,这被称为解构赋值

// todo 数组的解构(不常用)
const COLOR = ['red', 'green', 'yellow', 'blue'];
let [red, green, yellow, blue] = COLOR;
console.log(red); // red
console.log(green); // green
console.log(yellow); // yellow
console.log(blue); // blue

// todo 对象的解构(常用)
// @方法频繁调用,使用对象的解构赋值
const PERSON = {
  name: 'luck',
  age: 16,
  sayName: function () {
    console.log(PERSON.name);
  }
}

let { name, age, sayName } = PERSON;
console.log(name); //luck
console.log(age); //16
console.log(sayName); //ƒ () {console.log(this.name);}
sayName(); //luck